<%--
    Document   : newpromotion
    Created on : Nov 17, 2011, 12:33:29 PM
    Author     : Venus
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.*,  Beans.ThamSoHT,Models.ThamSoHT_Model, Models.MonAn_Model, Models.TienTe_Model"%>
<%
            int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
            String dsts = " 'all', 'notice', 'order', 'rightmsg' ";
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.

            String all = mdsts[0].getTenTS();            
            String notice = mdsts[1].getTenTS();
            String order = mdsts[2].getTenTS();
            String rightmsg = mdsts[3].getTenTS();
            String msgright = notice + "/" + rightmsg;            
            Vector vDSNT = (Vector) request.getAttribute("DSNT");

            Vector vDSMA = (Vector) request.getAttribute("DSMA");
            int numpage = 0;// khởi tạo số trang = 0
            int vsize = vDSMA.size();
            if (vsize % 6 == 0) // mỗi trang có 6 dòng
            {
                numpage = vsize / 6;
            } else {
                numpage = vsize / 6 + 1;
            }
            String xx = (String) request.getAttribute("item"); // trang hiện tại đang xem
            int item = Integer.parseInt(xx);
            String manma = (String) request.getAttribute("manma"); // trang hiện tại đang xem
%>
                <table  class="mytable" border="0" cellpadding="0" cellspacing="0">
                    <thead>
                <tr>
                    <th style="width: 8%;  "><%=order%></th>
                    <th style="width: 20%; ">
                        <a href="#" id="titledskv1" style="margin-top: 5px;" class="down" lang="<%=msgright%>" shape="<%=manma %>" name="1" onclick="SortTenMAKM(this.className, this.name, this.lang, this.shape)">
                            <div style="float:left">Ten Mon An</div>
                            <div id="sortkv1" style=" margin-right: 55px;" class="down1"></div>
                        </a>
                    </th>
                    <th style="width: 18%; ">
                        <a href="#" id="titledskv2" style="margin-top: 5px;" class="down" lang="<%=msgright%>" name="1" shape="<%=manma %>" onclick="SortNgayThuKM(this.className, this.name, this.lang, this.shape)">
                            <div style="float:left">Ngay thu</div>
                            <div id="sortkv2" style=" margin-right: 55px;" class="down1"></div>
                        </a>
                    </th>
                    <th style="width: 18%; ">
                        <a href="#" id="titledskv3" style="margin-top: 5px;" class="down" lang="<%=msgright%>" name="1" shape="<%=manma %>" onclick="SortGiaKM(this.className, this.name, this.lang, this.shape)">
                            <div style="float:left">Gia</div>
                            <div id="sortkv3" style=" margin-right: 55px;" class="down1"></div>
                        </a>
                    </th>
                    <th style="width: 18%; ">
                        <a href="#" id="titledskv1" style="margin-top: 5px;" class="down" lang="<%=msgright%>" name="1" >
                            <div style="float:left">Giam gia</div>                            
                        </a>
                    </th>

                    <th style=" margin-top: 2px;">
                        <a href="#" id="titledskv2" class="down"  name="1" lang="<%=msgright%>" >
                            <div>Sale Gia</div>                            
                        </a>
                    </th>
                </tr>
                <tr id="searchKM">
                    <th><img style=" margin-top: 2px;" alt="1" lang="<%=msgright%>" name="<%=manma %>" src="../images/search1.png" onclick="SearchKM(this.alt, this.lang, this.name)"></th>
                        <th><input type="textbox" class="tenmasearch" alt="1" size="17" lang="<%=msgright%>" name="<%=manma %>" onchange="SearchKM(this.alt, this.lang, this.name)"></th>
                        <th>
                            <div>
                                <select id="1" class="ngaythusearch" lang="<%=msgright%>" name="<%=manma %>" onchange="SearchKM(this.id, this.lang, this.name)">
                                    <option value="all"><%=all %></option>
                                    <%
                                        for (int i = 0; i < vDSNT.size(); i++){
                                            Beans.NgayThu nt = (Beans.NgayThu) vDSNT.elementAt(i);%>
                                            <option value="<%=nt.getMaNgay()%>"><%=nt.getTenNgay()%></option>
                                    <%  }
                                    %>
                                </select>
                            </div>
                        </th>
                        <th><input type="textbox" class="giasearch" alt="1" size="17" lang="<%=msgright%>" name="<%=manma %>" onchange="SearchKM(this.alt, this.lang, this.name)"></th>
                        <th></th>
                        <th></th>
                    </tr>
            </thead>
            <tbody>
                       <%
                            
                                for (int j = (item - 1) * 6; j < (item - 1) * 6 + 6 && j < vsize; j++) {
                            Beans.MonAn ma = (Beans.MonAn) vDSMA.elementAt(j);
                %>
                <tr>
                    <td class="STT"><%= j + 1%></td>
                    <td><%=ma.getTenMA() %></td>
                    <td>
                        <select name="ngaythu">
                    <%
                        for (int i = 0; i < vDSNT.size(); i++){
                            Beans.NgayThu nt = (Beans.NgayThu) vDSNT.elementAt(i);%>
                            <option value="<%=nt.getMaNgay()%>"><%=nt.getTenNgay()%></option>
                    <%  }
                    %>
                    </select>
                    </td>
                    <td><%=MonAn_Model.LayGia(ma.getMaMA())%></td>
                    <%
                        if(vDSMA.size() > 1){%>
                            <td>
                                <input style=" width: 50px;" type="text" lang="<%=MonAn_Model.LayGia(ma.getMaMA())%>" name="discountfood" class="text discountfood" alt="<%=ma.getMaMA()%>" onchange="LayRsGia(this.value, this.alt)" value="0" maxlength="2" >
                                <input type="hidden" class="count" name="count" value="2">
                            </td>

                    <%  }
                        else{%>
                            <td>
                                <input style=" width: 50px;" type="text" lang="<%=MonAn_Model.LayGia(ma.getMaMA())%>" name="discountfoodd" class="text discountfood" alt="<%=ma.getMaMA()%>" onchange="LayRsGia(this.value, this.alt)" value="0" maxlength="2" >
                                <input type="hidden" class="count" name="count" value="1">
                            </td>
                    <%  }
                    %>
                    <td><div id="rsgia<%=ma.getMaMA()%>" style="float: left; width: 50px;"><%=MonAn_Model.LayRsGia(ma.getMaMA(), 0 )%></div><%=TienTe_Model.LayKyHieuTT(langid)%></td>
                </tr>
                <%  }
                %>
            </tbody>
                </table>
            <div class="pagination">
                <%
                    int trang = 1;
                    if (item > 1) {
                        trang = item - 1;
                    }
                %>
                <%
                    if (vsize > 6) {%>
                        <a href="#" class="prev"  name="<%= trang%>" lang="<%=manma%>" onclick="ShowDSMA( this.name, this.lang)">«</a>
                <%      for (int c = 1; c <= numpage; c++) {
                            if (c != item) {
                %>              <a href="#"  name="<%= c%>" lang="<%=manma%>" onclick="ShowDSMA( this.name, this.lang)" ><%= c%></a>
                <%          } else {%><a class="current"> <%= c%></a> <% }
                        }
                %>
                <%      if (item + 1 <= numpage) {
                            trang = item + 1;
                        } else {
                            trang = item;
                        }
                %>
                        <a href="#" class="next"  name="<%= trang%>" lang="<%=manma%>" onclick="ShowDSMA( this.name, this.lang)">»</a>
                <%  }
                %>
            </div>
           